package main

import (
	"wallet/controllers"

	"github.com/gin-gonic/gin"
	"github.com/tommy351/gin-sessions"
	//"net/http"
)

func main() {
	r := gin.Default()

	store := sessions.NewCookieStore([]byte("secret123"))
	r.Use(sessions.Middleware("my_session", store))

	r.Static("/static", "./static")
	//r.StaticFS("/static", http.Dir("./static"))
	r.LoadHTMLGlob("templates/*")
	r.GET("/", controllers.Home)
	r.GET("/login", controllers.Login)
	r.GET("/index", controllers.Index)

	// 路由注册
	r.POST("/user", controllers.AddUser)
	r.POST("/book", controllers.AddBook)
	r.GET("/book", controllers.SelectBookList)
	r.GET("/bill", controllers.SelectBillList)
	r.POST("/bill", controllers.AddBill)
	r.GET("/bill/delete", controllers.DeleteBill)
	r.GET("/book/cash", controllers.Cash)
	r.POST("/userbook/add", controllers.AddUserBook)

	r.Run() // listen and serve on 0.0.0.0:8080
}
